import {defineStore} from 'pinia'
import {ref} from 'vue'
import i18n from '../locales'

export const useLocaleStore = defineStore('locale', {
  state: () => ({
    locale: i18n.global.locale.value, // 当前语言
    scrollHeight: 0, // 当前页面滚动高度
    menuList: [],
    systemDto: {}
  }),
  actions: {
    setLocale(lang) {
      this.locale = lang
      i18n.global.locale.value = lang
    },
    setScrollHeight (num) {
      this.scrollHeight = num
    },
    setMenuList(list) {
      this.menuList = list
    },
    setSystemDto(obj) {
      this.systemDto = obj
    }
  },
  persist:  true  // 这个配置代表存储生效，而且是整个store都存储
})
